package br.com.puertorico.model.querybuilder.annotations;

/**
 * List of possible operand used for query generation
 *
 * @author daniel.camargo
 */
public enum Operand {
	NONE {

		public String value() {
			return " ?";
		}
	},
	EQUAL {

		public String value() {
			return "= ?";
		}
	},
	GREATER {

		public String value() {
			return "> ?";
		}
	},
	GREATER_EQUAL {

		public String value() {
			return ">= ?";
		}
	},
	LESSER {

		public String value() {
			return "< ?";
		}
	},
	LESSER_EQUAL {

		public String value() {
			return "<= ?";
		}
	},
	DIFFERENT {

		public String value() {
			return "!= ?";
		}
	},
	IN {

		public String value() {
			return "IN ( ? )";
		}
	},
	NOT_IN {

		public String value() {
			return "NOT IN ( ? )";
		}
	},

	STARTS_WITH {

		public String value() {
			return "LIKE ?";
		}

		public String expression() {
			return super.expression() + "?%";
		}
	},
	ENDS_WITH {

		public String value() {
			return "LIKE ?";
		}

		public String expression() {
			return super.expression() + "%?";
		}
	},

	CONTAINS {

		public String value() {
			return "LIKE ?";
		}

		public String expression() {
			return super.expression() + "%?%";
		}
	},

	IS_NOT_NULL {
		@Override
		public String value() {
			return "";
		}
	},

	IS_NULL {
		@Override
		public String value() {
			return "";
		}
	}

	;

	/**
	 * Value of the operand. Its the actual string that will be placed in the
	 * string
	 *
	 * @return
	 */
	public abstract String value();

	/**
	 * Used for LIKE operations where we need to know the right place to insert
	 * the '%'
	 *
	 * @return
	 */
	public String expression() {
		return "";
	}
}
